    //
//  YAYIPersoninfoHeadCell.m
//  yayi
//
//  Created by Veer on 16/3/18.
//  Copyright © 2016年 hxp. All rights reserved.
//

#import "YAYIPersoninfoHeadCell.h"

#import "YAYISettingItemModel.h"


@interface YAYIPersoninfoHeadCell()

@end

@implementation YAYIPersoninfoHeadCell

- (void)setModel:(YAYISettingItemModel *)model
{
    //[super setItem:item];
    _model = model;
    
    self.textLabel.text = model.name;
    
    NSURL *url = [NSURL URLWithString:model.icon];
//    [self.iconVw sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"default"]];
    [self.iconVw sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"default"] options:SDWebImageRefreshCached];
    
}

+ (instancetype)cellWith:(UITableView *)tableview
{
    static NSString *cellID = @"mecell";
    
    YAYIPersoninfoHeadCell *cell = [tableview dequeueReusableCellWithIdentifier:cellID];
    //YAYIPersoninfoCell *cell = [super cellWith:tablevie];
    
    if (nil == cell) {
        cell = [[YAYIPersoninfoHeadCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellID];
    }
    
    return cell;
}



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        self.textLabel.font = [UIFont systemFontOfSize:15];
        self.textLabel.textColor = YAYIColor(92, 92, 92);
    
        self.detailTextLabel.font = [UIFont systemFontOfSize:15];
        self.detailTextLabel.textColor = YAYIColor(92, 92, 92);
        
        [self setupSubview];
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat margin = 10;
    // 设置frame
    [self.iconVw mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(margin);
        make.bottom.mas_equalTo(-margin);
        make.trailing.mas_equalTo(-margin);
        make.width.mas_equalTo(self.iconVw.mas_height);
    }];
}


- (void)setupSubview
{
    //
    UIImageView *iconVw = [[UIImageView alloc] init];
    iconVw.contentMode = UIViewContentModeScaleAspectFill;
    iconVw.clipsToBounds = YES;
    iconVw.layer.cornerRadius = 35;
    [self.contentView addSubview:iconVw];
    self.iconVw = iconVw;
    
    //
    UILabel *nameLbl = [[UILabel alloc] init];
    nameLbl.font = [UIFont systemFontOfSize:17];
    //nameLbl.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:nameLbl];
    self.nameLbl = nameLbl;
    
}


@end
